package com.xisoft.devise.service.impl;

import com.xisoft.base.entity.ReferEntity;
import com.xisoft.common.pubEnv.JudgeAssertUtil;
import com.xisoft.common.pubEnv.PubEnvUtil;
import com.xisoft.devise.entity.metadata.DicTableFieldVO;
import com.xisoft.devise.entity.metadata.DicTableVO;

import java.util.Map;

/**
 * *
 * Created with Description:
 *
 * @version 1.0 <br>
 * @packagename: com.xisoft.devise.service.impl<br>
 * @author: LiBencheng <br>
 * @computer: licheng <br>
 * @date: Created on 2022/9/23 11:02 <br>
 */
public class CheckUtil
{

    static void checkRefObj(ReferEntity refEntity)
    {
        JudgeAssertUtil.checkAssert(PubEnvUtil.isEmpty(refEntity.getTableName()),
                                    "參照表名不能为空[tableName]不能为空，请检查！");
        JudgeAssertUtil.checkAssert(PubEnvUtil.isEmpty(refEntity.getPkName()),
                                    "參照对象主键不能为空[pkName]不能为空，请检查！");
        JudgeAssertUtil.checkAssert(PubEnvUtil.isEmpty(refEntity.getFieldName()),
                                    "參照对象对应字段不能为空[fieldName]不能为空，请检查！");
    }

    static void checkMetaTable(Map< String,Object > tabMap)
    {
        JudgeAssertUtil.checkAssert(PubEnvUtil.isEmptyObj(tabMap.get(DicTableVO.SDT_TABLE_EN_NAME)),
                                    "表名/视图名[sdt_table_en_name]不能为空,必填！");
        JudgeAssertUtil.checkAssert(PubEnvUtil.isEmptyObj(tabMap.get(DicTableVO.SDT_SYSTEM_NAME)),
                                    "系统名称[sdt_system_name]不能为空,必填！");

    }

    static void checkMetaField(Map< String,Object > fieldMap)
    {
        JudgeAssertUtil.checkAssert(PubEnvUtil.isEmptyObj(fieldMap.get(DicTableFieldVO.SDF_FIELD_EN_NAME)),
                                    "字段名称[sdf_field_en_name]不能为空,必填！");
        JudgeAssertUtil.checkAssert(PubEnvUtil.isEmptyObj(fieldMap.get(DicTableFieldVO.SDF_FIELD_TYPE)),
                                    "字段类型[sdf_field_type]不能为空,必填！");
        JudgeAssertUtil.checkAssert(PubEnvUtil.isEmptyObj(fieldMap.get(DicTableFieldVO.SDF_FIELD_LENGTH)),
                                    "字段长度[sdf_field_length]不能为空,必填！");
    }

    
}
